//
//  ViewController.m
//  iOS
//
//  Created by zhangxin on 16/2/29.
//  Copyright © 2016年 zhangxin. All rights reserved.
//

#import "ViewController.h"
#import "otherclass.h"
@interface ViewController ()
{
    UILabel * mylable;
    UIButton * button;
    
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    mylable = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 200, 40)];
    mylable.backgroundColor = [UIColor yellowColor];
    mylable.text = @"张鑫";
    
    //标签的设置居中
    mylable.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:mylable];
    
    
    button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(50, 70, 220, 20);
    [button setTitle:@"🔘 我的按钮" forState:UIControlStateNormal];
    [button setTitle:@"点击状态" forState:UIControlStateHighlighted];
    //[button addTarget:self action:@selector(action) forControlEvents:UIControlEventTouchUpInside];
    otherclass *myc = [[otherclass alloc]init];
    [button addTarget:myc action:@selector(myAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    
}

/*- (void)action
{
    NSLog(@"这个按钮被点击");
}*/

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
